<?php
/**
 * Created by PhpStorm.
 * User: hao
 * Date: 2018/10/27
 * Time: 9:57 AM
 */

namespace app\api\validate;


class IDCollection extends BaseValidate
{
    protected $rule = [
        'ids' => 'require|checkIDs'
    ];

    protected $message = [
        'ids' => 'ids必须是以逗号分隔的多个整数'
    ];

    protected function checkIDs($value) {
        $values = explode(',',$value);
        if (empty($values)) {
            return false;
        }
        foreach ($values as $id) {
            if (!$this->idPostiveInteger($id)){
                return false;
            }
        }
        return true;
    }
}